<?php

namespace app\admin\model;

use think\Model;


class Notice extends Model
{

    

    

    // 表名
    protected $name = 'notice';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'status_text',
        'read_text'
    ];
    

    
    public function getTypeList()
    {
        return ['0' => __('Type 0'), '1' => __('Type 1'), '3' => __('Type 3')];
    }
    
    public function getStatusList()
    {
        //'2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4')
        return ['1' => __('Status 1')];
    }

    public function getReadList()
    {
        return ['0' => __('Read 0'), '1' => __('Read 1')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ?: ($data['status'] ?? '');
        $list = $this->getStatusList();
        return $list[$value] ?? '';
    }


    public function getReadTextAttr($value, $data)
    {
        $value = $value ?: ($data['read'] ?? '');
        $list = $this->getReadList();
        return $list[$value] ?? '';
    }




}
